<?php
/*
 * @Name     : rujuezbp Include
 * @Author   : 胖蟹
 * @Support  : www.rujue.cn
 */

RegisterPlugin('rujuezbp', 'ActivePlugin_rujuezbp');

function ActivePlugin_rujuezbp(){
    global $zbp;
    $name = 'rujuezbp';

    Add_Filter_Plugin('Filter_Plugin_Post_Get', $name . '_PostGet');
}
function rujuezbp_PostGet(&$post, $name){
    global $zbp;

    switch ($name) {
    case 'Cover':// 获取文章第一张图片
      preg_match_all('/<img[^>]*?\s+src="([^\s"]{5,})"(\/?>|\s[^<]*?>)/i', $post->Intro . $post->Content, $imgs);
      $post->$name = isset($imgs[1][0]) ? $imgs[1][0] : $zbp->Config('rujuezbp')->Cover;
    break;
    case 'TimeUrl':// 不明白
      $url = new UrlRule($zbp->option['ZC_DATE_REGEX']);
      $url->Rules['{%date%}'] = $post->Time('Y-m-d');
      $url->Rules['{%year%}'] = $post->Time('Y');
      $url->Rules['{%month%}'] = $post->Time('m');
      $url->Rules['{%day%}'] = $post->Time('d');
      $post->$name = $url->Make();
    break;
  }
}
// 是否是移动设备的判断
function rujuezbp_IsMoblie(){
    $ua = GetGuestAgent();
    if (preg_match('/(Android|Web0S|webOS|iPad|iPhone|Mobile|Windows\sPhone|Kindle|BlackBerry|Opera\sMini)/', $ua)){return true;}
    return false;
}

?>